<?
include 'common/autoload.php';
include 'common/header.html';
include 'common/left.html';
use \pft\notice;
use \pft\Prod\Product;
$notice = new notice();
$s = new Product($GLOBALS['le']);
$did = $_SESSION['memberID'];
$dtype = $_SESSION['dtype'];
$state = isset($_GET['state'])?abs($_GET['state']) : 3;
if(empty($_GET) && $_SESSION['dtype']==0 || isset($_GET['outbox'])) {
    $params = array('adminid'=>$did,'limit'=>0,'offset'=>100);
    $sflag = '&s=1';
    $lists = $notice->GetNoticeList(notice::SEND,$params);
}
elseif(isset($_GET['inbox']) || $_SESSION['dtype']>0 || !empty($_GET)) {
    $params = array(
        'adminid'=>$did,
        'rs'=>$state,
        'limit'=>0,
        'offset'=>100
    );
    $lists = $notice->GetNoticeList(notice::RECIVE,$params);
}

//print_r($lists);
$chk_state =  array('<span class="orange">[未审核]</span>','<span class="glree">[已审核]</span>',
                    '<span class="red">[拒绝]</span>','<span class="red">[删除]</span>');
$read_state = array('<span class="glree">[未读]</span>','<span class="grey">[已读]</span>');
$titleList = array(1=>'上架','下架','涨价','降价');
?>
    <script> document.title="系统通知 - <?=$GLOBALS['web_title']?>";</script>
	<link rel="stylesheet" type="text/css" href="css/my_color.css"/>
    <link rel="stylesheet" href="css/aliceui.min.css">
    <link rel="stylesheet" type="text/css" href="css/resetui.css"/>
    <link rel="stylesheet" type="text/css" href="css/noticet.css"/>
    <link rel="stylesheet" type="text/css" href="css/jPages.css" />
<div class="r_content">
    <h3 class="mc_title">
        <span class="mctit_1"><span class="mctit_2">系统通知</span></span>
    </h3>
    <div class="notiul">
	<ul id="tagsa">
        <?if($_SESSION['dtype']==0 || $_SESSION['dtype']==9){?>
    	    <a href="Sendnotice.html" class="addnot">发布通知</a>
            <li class="<?=!isset($_GET['inbox'])?'selectTaga':'';?>"><a href="?outbox" class="notta">已发送通知</a></li>
            <li class="<?=isset($_GET['inbox'])?'selectTaga':'';?>"><a href="?inbox" class="notta">收到的通知</a></li>
        <?} else {?>
            <li class="selectTaga"><a href="?inbox" class="notta">收到的通知</a></li>
        <? }?>
    </ul>
</div>
    <input value="<?=$did?>" type="hidden" name="did"/>
    <div class="clay">
    <?if(!isset($sflag)){?>
	<ul class="clayul">
        <li class="<?=$_GET['state']==3 ||!isset($_GET['state'])?'currentli':''?>" ><a href="?state=3" class="clayula">所有通知</a></li>
        <li class="<?=$_GET['state']==0 && is_numeric($_GET['state'])?'currentli':''?>" ><a href="?state=0" class="clayula">未读通知</a></li>
        <li class="<?=$_GET['state']==1?'currentli':''?>" ><a href="?state=1" class="clayula">已读通知</a></li>
    </ul>
    <?}?>
    <ul class="box" id="itemContainer">
        <?if(count($lists)) {foreach($lists as $list){?>
            <?php $dname = $list['adminid']==1 ? '系统' : $list['dname']?>
            <li id="li_<?=$list['id']?>">
            	<span class="date"><?=$list['btime']?></span>
                <span><input type="checkbox" class="chkbox" name="checkbox1"value="<?=$list['id']?>"/></span>
                <?=!isset($_GET['outbox'])?$read_state[$list['rstate']]:''?>
                <?if(isset($_GET['inbox']) || $_SESSION['dtype']>0){?>
                    <span class="from">from:<?=$dname?></span>
                <?}?>
                <?if($list['sms_notify']){?>
                    <img src="images/icons/icon_mobile.png" title="有短信通知" alt="短信"/>
                <?}?>
                <span class="title">
                    <a href="noticed.html?id=<?=$list['id'].$sflag?>" target="_blank">[<?=substr($list['btime'],0, 10)?>]<?=$list['title']?></a>
                </span>
            </li>
        <?}} else {?>
            <p>您目前没有未读的通知</p>
        <?}?>
    </ul>
    <div class="btn_gray">
	     <input type="button" name="btnCheckedAll" value="全选" onclick="javascript:$(':checkbox[name=checkbox1]').attr('checked','checked');" />
        <!--  <span><input type="checkbox" class="chkbox" value=""/></span> -->
		<input type="button" class="ui-button ui-button-sblue btnSetState" data-state="1" value="标记为已读" />
        <input type="button" class="ui-button ui-button-sblue btnSetState" data-state="<?=isset($_GET['outbox'])?4:2?>" value="删除" />
        <span id="holder" class="holder"></span>
    </div>
</div>
</div>
    <script src="js/jPages.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/notice.js"></script>
    <script type="text/javascript">
        $(function(){
            $("span#holder").jPages({ containerID : 'itemContainer',previous : "←",next : "→",perPage : 15,delay : 1});
        });
    </script>
<?include("common/footer.html")?>